package com.ftqh.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter{
	/* 
	 * 添加跨域访问
	 */
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")
				.allowedOrigins("*")	//允许来自所有域的请求
				.allowedMethods("GET", "POST", "HEAD", "PUT", "DELETE")	//允许哪些请求方法
				.allowedHeaders("Accept", "Origin", "X-Requested-With", "Content-Type", "Last-Modified")
				.exposedHeaders("Set-Cookie")
				.allowCredentials(true);
		super.addCorsMappings(registry);
	}

	
}
